<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018/8/23 0023
 * Time: 9:18
 */
namespace app\admin\model;

class Page
{
    /**获取后台用户的分页
     * @param null $field
     * @return mixed
     */
    static  $limit = 10;
    static public function AdminUser($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                $data = UserModel::getAdminUser()->where($where)->order($field)->paginate($limit)->toArray();
                return $data;
            }else{
                $data = UserModel::getAdminUser()->order($field)->paginate($limit)->toArray();
                return $data;
            }
        }else{
            if($where){
                $data = UserModel::getAdminUser()->where($where)->paginate($limit)->toArray();
                return $data;
            }else{
                $data = UserModel::getAdminUser()->paginate($limit)->toArray();
                return $data;
            }
        }
    }
    //获取前台用户的分页
    static public function IndexUser($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        //return $limit;
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return UserModel::getIndexUser()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return UserModel::getIndexUser()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return UserModel::getIndexUser()->where($where)->paginate($limit)->toArray();
            }else{
                return UserModel::getIndexUser()->paginate($limit)->toArray();
            }
        }
    }

    /**获取打卡记录分页
     * @param null $field
     * @return mixed
     */
    static public function Clock($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return ClockModel::getClock()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return ClockModel::getClock()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return ClockModel::getClock()->where($where)->paginate($limit)->toArray();
            }else{
                return ClockModel::getClock()->paginate($limit)->toArray();
            }
        }
    }

    /**请假记录分页
     * @param null $field
     * @return mixed
     */
    static public function Leave($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return LeaveModel::getLeave()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return LeaveModel::getLeave()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return LeaveModel::getLeave()->where($where)->paginate($limit)->toArray();
            }else{
                return LeaveModel::getLeave()->paginate($limit)->toArray();
            }
        }
    }

    /**打卡设置分页
     * @param null $field
     * @return mixed
     */
    static public function Setting($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return SettingModel::getSetting()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return SettingModel::getSetting()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return SettingModel::getSetting()->where($where)->paginate($limit)->toArray();
            }else{
                return SettingModel::getSetting()->paginate($limit)->toArray();
            }
        }
    }

    /**公司分页
     * @param null $field
     * @return false|\PDOStatement|string|\think\Collection
     */
    static public function Company($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return CompanyModel::getCompany()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return CompanyModel::getCompany()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return CompanyModel::getCompany()->where($where)->paginate($limit)->toArray();
            }else{
                return CompanyModel::getCompany()->paginate($limit)->toArray();
            }
        }
    }

    /**公司部门分页
     * @param null $field
     * @return mixed
     */
    static public function Departmen($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return DepartmenModel::getDepartmen()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return DepartmenModel::getDepartmen()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return DepartmenModel::getDepartmen()->where($where)->paginate($limit)->toArray();
            }else{
                return DepartmenModel::getDepartmen()->paginate($limit)->toArray();
            }
        }
    }

    /**职位分页
     * @param null $field
     * @return mixed
     */
    static public function Position($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return PositionModel::getPosition()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return PositionModel::getPosition()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return PositionModel::getPosition()->where($where)->paginate($limit)->toArray();
            }else{
                return PositionModel::getPosition()->paginate($limit)->toArray();
            }
        }
    }

    /**公司权限分页
     * @param null $field
     * @return false|\PDOStatement|string|\think\Collection
     */
    static public function Jurisdiction($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return JurisdictionModel::getJurisdiction()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return JurisdictionModel::getJurisdiction()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return JurisdictionModel::getJurisdiction()->where($where)->paginate($limit)->toArray();
            }else{
                return JurisdictionModel::getJurisdiction()->paginate($limit)->toArray();
            }
        }
    }

    /**公告分页
     * @param null $field
     * @return mixed
     */
    static public function Notice($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($where==['notice.notice_type'=>0]){
            $true = false;
        }else{
            $true = true;
        }
        if($field){
            if($where){
                return NoticeModel::getNotice($true)->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return NoticeModel::getNotice($true)->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return NoticeModel::getNotice($true)->where($where)->paginate($limit)->toArray();
            }else{
                return NoticeModel::getNotice($true)->paginate($limit)->toArray();
            }
        }
    }

    /**工作报告分页
     * @param null $field
     * @return mixed
     */
    static public function Report($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return ReportModel::getReport()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return ReportModel::getReport()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return ReportModel::getReport()->where($where)->paginate($limit)->toArray();
            }else{
                return ReportModel::getReport()->paginate($limit)->toArray();
            }

        }
    }

    /**积分变更记录分页
     * @param null $field
     * @return mixed
     */
    static public function Integral($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return IntegralModel::getIntegral()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return IntegralModel::getIntegral()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return IntegralModel::getIntegral()->where($where)->paginate($limit)->toArray();
            }else{
                return IntegralModel::getIntegral()->paginate($limit)->toArray();
            }
        }
    }

    /**职位发布分页
     * @param null $field
     * @return mixed
     */
    static public function Release($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return ReleaseModel::getRelease()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return ReleaseModel::getRelease()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return ReleaseModel::getRelease()->where($where)->paginate($limit)->toArray();
            }else{
                return ReleaseModel::getRelease()->paginate($limit)->toArray();
            }
        }
    }

    /**评论表分页
     * @param null $field
     * @return mixed
     */
    static public function Comment($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return CommentModel::getComment()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return CommentModel::getComment()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return CommentModel::getComment()->where($where)->paginate($limit)->toArray();
            }else{
                return CommentModel::getComment()->paginate($limit)->toArray();
            }
        }
    }

    /**公司产品分页
     * @param null $where
     * @param null $field
     * @return false|\PDOStatement|string|\think\Collection
     */
    static public function Products($where=null,$field=null){
        $limit = \request()->param('limit',self::$limit);
        if($limit==''||$limit==' '){
            $limit =self::$limit;
        }
        if($field){
            if($where){
                return ProductsModel::getProducts()->where($where)->order($field)->paginate($limit)->toArray();
            }else{
                return ProductsModel::getProducts()->order($field)->paginate($limit)->toArray();
            }
        }else{
            if($where){
                return ProductsModel::getProducts()->where($where)->paginate($limit)->toArray();
            }else{
                return ProductsModel::getProducts()->paginate($limit)->toArray();
            }
        }
    }
}